const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('sys_user', {
    id: {
      autoIncrement: true,
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: "id"
    },
    account: {
      type: DataTypes.STRING(100),
      allowNull: false,
      comment: "账号",
      unique: "User_un"
    },
    password: {
      type: DataTypes.STRING(100),
      allowNull: false,
      comment: "密码"
    },
    uname: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: "昵称"
    },
    avatar: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: "头像"
    },
    tel: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: "电话号码"
    },
    email: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: "邮箱"
    },
    permission: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 1,
      comment: "权限"
    },
    createTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "创建时间"
    },
    updateTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "更新时间"
    }
  }, {
    sequelize,
    tableName: 'sys_user',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
      {
        name: "User_un",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "account" },
        ]
      },
    ]
  });
};
